package com.mike.spring.IOC;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class HongKongNewsProvider implements BeanFactoryAware,BeanNameAware {
    @Autowired
    @Qualifier("hongKongNewsListener")
    private NewsListener hongKongNewsListener2;



    public void getNews() {
        hongKongNewsListener2.getNews();
    }

    @PostConstruct //相当于 <bean id="fXNewsProvider" class="com.mike.spring.IOC.FXNewsProvider" init-method="init_test" name="fxNews">中的init-method
    public void postConstruct(){
        System.out.println("HongKongNewsProvider postConstruct");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("test");
    }

    @Override
    public void setBeanName(String name) {
        System.out.println(name);
    }
}
